Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter: notch filter: remove unneeded value and pre-multiply for speed #24250

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

IamPete1
Copy link
Member

@IamPete1 IamPete1 commented Jul 8, 2023

I had spotted we could pre-multiply by a0 to same some runtime calculation and was looking at the betaflight filter code and they also have different handling of the "memory" elements that saves one value.

https://github.com/betaflight/betaflight/blob/90d09e2e5bccc9e21101811618be79621286f56e/src/main/common/filter.c#L210-L224

I have run this in my MATLAB thingy (#24249) result is the same to 10^-4. floating point math does mean the result comes out a tiny bit different. The difference is only due to the pre-multiplication of a0. The removal of ntchsig makes no difference to the result.

Copy link
Contributor

@lthall lthall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Collaborator

@andyp1per andyp1per left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM will need a real flight test

@IamPete1
Copy link
Member Author

Rebased and tested on the bench. Still getting good agreement with post filter estimate from filter tool, so all seems to be working as before.
newplot(4)

@CraigElder CraigElder changed the title Flter: notchfilter: remove unneeded value and pre-multiply for speed Filter: notchfilter: remove unneeded value and pre-multiply for speed Oct 16, 2023
@CraigElder CraigElder changed the title Filter: notchfilter: remove unneeded value and pre-multiply for speed Filter: notch filter: remove unneeded value and pre-multiply for speed Oct 16, 2023
@tridge tridge merged commit 3c6ddda into ArduPilot:master Oct 16, 2023
86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants